<extend name="Public/common" />
<block name="body">
<script type="text/javascript" src="__JS__/jquery-ui/jquery.ui.js"></script>
<script type="text/javascript" src="__JS__/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="__JS__/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>菜谱管理</h3>
      <ul class="tab-base">
        	<li><a href="{:U('index')}"><span>列表</span></a></li>
	        <li><a href="{:U('add')}"><span>新增</span></a></li>
	        <li><a href="JavaScript:void(0);" class="current"><span>编辑</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="form1" method="post" enctype="multipart/form-data" name="form1">
    <input type="hidden" name="id" value="{$info['id']}" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="area_id">区域选择:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><select class='class-select' name="area_id" id="area_id">
              <option value="">区域名称</option>
		      <notempty name="area">
		      <volist name="area" id="vo">
              <option <eq name="info.area_id" value="$key">selected='selected'</eq> value="{$key}">{$vo}</option>
              </volist>
              </notempty>
            </select></td>
          <td class="vatop tips">区域名称 必须选择</td>
        </tr>

        <tr>
            <td colspan="2" class="required"><label class="validation" for="store_id">商户选择:</label></td>
        </tr>
        <tr class="noborder">
            <td id="gstore" class="vatop rowform"><select class='class-select' name="store_id" id="store_id">
                <option value="">-请选择-</option>
                <notempty name="store">
                    <volist name="store" id="vo">
                        <option <eq name="info.store_id" value="$key">selected='selected'</eq> value="{$key}">{$vo}</option>
                    </volist>
                </notempty>
            </select></td>
            <td class="vatop tips">商户名称 必须选择</td>
        </tr>

        <tr>
          <td colspan="2" class="required"><label class="validation" for="goods_id">商品选择:</label></td>
        </tr>
        <tr class="noborder">
          <td id="ggoods" class="vatop rowform"><select class='class-select' name="goods_id" id="goods_id">
              <option value="">-请选择-</option>
		      <notempty name="goods">
		      <volist name="goods" id="vo">
              <option <eq name="info.goods_id" value="$vo.goods_id">selected='selected'</eq> value="{$vo['goods_id']}">{$vo['goods_name']}</option>
              </volist>
              </notempty>
            </select></td>
          <td class="vatop tips">商品名称 必须选择</td>
        </tr> 
                
        <tr class="noborder">
          <td class="required"><label>出售开始时间: </label></td>
          <td colspan="2" class="required"><label>出售截止时间: </label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform" style="width:400px;"><input type="text" name="start_sell_time" id="start_sell_time" class="txt date" style="width:100px;" value="{:@date('Y-m-d', $info['start_sell_time'])}"/>日
            <select id="start_sell_hour" name="start_sell_hour" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="hour" id="vo">
              <option <if condition="date('H', $info['start_sell_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>时
            <select id="start_sell_minute" name="start_sell_minute" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="minute" id="vo">
              <option <if condition="date('i', $info['start_sell_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>分
          </td>
          <td class="vatop rowform" style="width:400px;"><input type="text" name="end_sell_time" id="end_sell_time" class="txt date" style="width:100px;" value="{:@date('Y-m-d', $info['end_sell_time'])}"/>日
            <select id="end_sell_hour" name="end_sell_hour" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="hour" id="vo">
              <option <if condition="date('H', $info['end_sell_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>时
            <select id="end_sell_minute" name="end_sell_minute" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="minute" id="vo">
              <option <if condition="date('i', $info['end_sell_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>分
		  </td>
          <td class="vatop tips"></td>
        </tr>
        
        <tr class="noborder">
          <td class="required"><label>配送开始时间: </label></td>
          <td colspan="2" class="required"><label>配送截止时间: </label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform" style="width:400px;"><input type="text" name="start_deliver_time" id="start_deliver_time" class="txt date" style="width:100px;" value="{:@date('Y-m-d', $info['start_deliver_time'])}"/>日
            <select id="start_deliver_hour" name="start_deliver_hour" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="hour" id="vo">
              <option <if condition="date('H', $info['start_deliver_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>时
            <select id="start_deliver_minute" name="start_deliver_minute" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="minute" id="vo">
              <option <if condition="date('i', $info['start_deliver_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>分
          </td>
          <td class="vatop rowform" style="width:400px;"><input type="text" name="end_deliver_time" id="end_deliver_time" class="txt date" style="width:100px;" value="{:@date('Y-m-d', $info['end_deliver_time'])}"/>日
            <select id="end_deliver_hour" name="end_deliver_hour" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="hour" id="vo">
              <option <if condition="date('H', $info['end_deliver_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>时
            <select id="end_deliver_minute" name="end_deliver_minute" style="margin-left: 8px; _margin-left: 4px; width:50px;">
              <volist name="minute" id="vo">
              <option <if condition="date('i', $info['end_deliver_time']) eq $vo" value="$vo">selected='selected'</if> value="{$vo}">{$vo}</option>
              </volist>
            </select>分
		  </td>
          <td class="vatop tips"></td>
        </tr>
        
        <tr>
          <td colspan="2" class="required"><label class="validation" for="goods_storage">库存数量:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_storage']}" name="goods_storage" id="goods_storage" class="txt2"></td>
          <td class="vatop tips">库存数量必须填写 更改请慎重 卖完即售罄</td>
        </tr>
 
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submit"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript" src="__JS__/common_select.js" charset="utf-8"></script>
<script type="text/javascript">
storeInit("gstore");
$(document).ready(function(){
	$('#start_sell_time').datepicker({dateFormat: 'yy-mm-dd'});
	$('#end_sell_time').datepicker({dateFormat: 'yy-mm-dd'});
	$('#start_deliver_time').datepicker({dateFormat: 'yy-mm-dd'});
	$('#end_deliver_time').datepicker({dateFormat: 'yy-mm-dd'});	
	$('#form1').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
        	area_id : {
                required : true
            },
            store_id : {
                required : true
            },
            goods_id : {
                required : true
            },
            start_sell_time : {
                required : true,
                date  : true 
            },
            end_sell_time : {
                required : true,
                date  : true 
            },
            start_deliver_time : {
                required : true,
                date  : true 
            },
            end_deliver_time : {
                required : true,
                date  : true 
            },
            goods_storage : {
            	required : true,
                number   : true
            }
        },
        messages : {
        	area_id : {
                required : "请选择区域"
            },
            goods_id : {
                required : "请选择商户"
            },
            store_id : {
                required : "请选择商品"
            },
            start_sell_time : {
                required : "请填写开始出售时间",
                date : "开始出售时间必须是年月日格式"
            },
            end_sell_time : {
                required : "请填写截止出售时间",
                date : "截止出售时间必须是年月日格式"
            },
            start_deliver_time : {
                required : "请填写开始配送时间",
                date : "开始配送时间必须是年月日格式"
            },
            end_deliver_time : {
                required : "请填写截止配送时间",
                date : "截止配送时间必须是年月日格式"
            },
            goods_storage : {
            	required : "请填写库存数量",
                number   : "库存只能为数字"
            }
        }
    });

	$("#submit").click(function() {
		if ($("#form1").valid()) {
			$("#form1").submit();
		}
	});
});
</script>
</block>